package com.l.d.app.library.util;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.util.DisplayMetrics;
import android.view.WindowManager;

/**
 * Created by linde on 2017/04/18.
 * <p/>
 */

public class WindowUtil {
    public static DisplayMetrics displayMetrics(@NonNull Context context) {
        DisplayMetrics dm = new DisplayMetrics();
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(dm);
        return dm;
    }

    public static <T extends DialogFragment> T dismiss(T dialog) {
        if (dialog != null) {
            dialog.dismiss();
        }
        return null;
    }
}
